<#include "/common/include.html">
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="操作日志">
	<@cssLibs.bootstrap_select_css/>
</@header>
<@search fromId="operlog-form">
<div class="select-list">
	<ul>
		<li>
			<label>系统模块： </label><input type="text" name="title"/>
		</li>
		<li>
			<label>操作人员： </label><input type="text" name="operName"/>
		</li>
		<li class="select-selectpicker">
			<label>操作类型： </label>
			<select id="businessTypes" class="selectpicker" data-none-selected-text="请选择" multiple>
				<#list dict.getType('sys_oper_type')>
					<#items as d>
						<#if d.status =='0' >
							<option value="${d.dictValue}" text="${d.dictLabel}">${d.dictLabel}</option>
						</#if>
					</#items>
				</#list>
			</select>
		</li>
		<li>
			<label>操作状态：</label>
			<select name="status" class="form-control">
				<option value="">所有</option>
				<#list dict.getType('sys_common_status')>
					<#items as d>
						<#if d.status =='0' >
							<option value="${d.dictValue}" text="${d.dictLabel}">${d.dictLabel}</option>
						</#if>
					</#items>
				</#list>
			</select>
		</li>
		<li class="select-time">
			<label>操作时间： </label>
			<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
			<span>-</span>
			<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
		</li>
		<li>
			<a class="btn btn-primary btn-rounded btn-sm" onclick="searchPre()"><i class="fa fa-search"></i>&nbsp;<@ctx.i18n text = "查询"/></a>
			<a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;<@ctx.i18n text = "重置"/></a>
		</li>
	</ul>
</div>
</@search>
<@table tableId="bootstrap-table">
	<@shiro.hasPermission name="sys:log:del">
		<a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">
			<i class="fa fa-remove"></i> 删除
		</a>
	</@shiro.hasPermission>
	<@shiro.hasPermission name="sys:log:clean">
		<a class="btn btn-danger" onclick="$.operate.clean()">
			<i class="fa fa-trash"></i> 清空
		</a>
	</@shiro.hasPermission>
</@table>
<@footer>
<@jsLibs.bootstrap_select_js/><#--引入jsLibs.bootstrap_select_js-->
<script>
	var detailFlag = "${permission.hasPermi('sys:log:detail')}";
	var datas = ${dict.getDictListJson('sys_oper_type')};
	var prefix = baseURL + "sys/operlog";

	$(function() {
		var options = {
			url: prefix + "/list",
			cleanUrl: prefix + "/clean",
			detailUrl: prefix + "/detail/{id}",
			delUrl: prefix + "/remove",
			sortName: "operTime",
			sortOrder: "desc",
			uniqueId: "operId", /* 唯一ID */
			modalName: "操作日志",
			escape: true,
			showPageGo: true,
			columns: [
			{
				title: "<@ctx.i18n text = "序号"/>", width: 10, formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
			},
			{
				field: 'title',
				title: '系统模块'
			},
			{
				field: 'businessType',
				title: '操作类型',
				align: 'center',
				formatter: function(value, row, index) {
					return $.table.selectDictLabel(datas, value);
				}
			},
			{
				field: 'operName',
				title: '操作人员',
				sortable: true
			},
			{
				field: 'compName',
				title: '公司名称'
			},
			{
				field: 'operIp',
				title: '主机'
			},
			{
				field: 'operLocation',
				title: '操作地点'
			},
			{
				field: 'status',
				title: '操作状态',
				align: 'center',
				formatter: function(value, row, index) {
					if (value == 0) {
						return '<span class="badge badge-primary">成功</span>';
					} else if (value == 1) {
						return '<span class="badge badge-danger">失败</span>';
					}
				}
			},
			{
				field: 'operTime',
				title: '操作时间',
				sortable: true
			},
			{
				field: 'time',
				title: '响应时间',
				formatter: function(value, row, index) {
						return value+'毫秒';
				}
			},
			{
				title:"<@ctx.i18n text = "操作"/>",
				align: 'center',
				formatter: function(value, row, index) {
					var actions = [];
					actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="opt.operate.detail(\'' + row.operId + '\')"><i class="fa fa-search"></i>详细</a>');
					return actions.join('');
				}
			}]
		};
		$.table.init(options);
	});

	function searchPre() {
		var data = {};
		data.businessTypes = opt.common.join($('#businessTypes').selectpicker('val'));
		$.table.search('operlog-form', 'bootstrap-table', data);
	}

	function resetPre() {
		opt.form.reset();
		$("#businessTypes").selectpicker('refresh');
	}
</script>
</@footer>
</@pageTheme>